2021-05-24 10:25:02 +00:00
|
|
|
import { validateIconSet } from '../lib/icon-set/validate';
|
|
|
|
|
|
|
|
describe('Testing validating alias', () => {
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Empty', () => {
|
2021-05-24 10:25:02 +00:00
|
|
|
expect(
|
|
|
|
validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {},
|
|
|
|
})
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {},
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Null', (done) => {
|
2021-05-24 10:25:02 +00:00
|
|
|
try {
|
|
|
|
validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: null,
|
|
|
|
});
|
|
|
|
done('Expected to throw error when aliases is null');
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: null,
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Invalid parent', (done) => {
|
2021-05-24 10:25:02 +00:00
|
|
|
try {
|
|
|
|
const result = validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
done(
|
|
|
|
'Expected to throw error when alias has missing parent, got ' +
|
|
|
|
JSON.stringify(result)
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Invalid parent, 2 levels', (done) => {
|
2021-05-24 10:25:02 +00:00
|
|
|
try {
|
|
|
|
const result = validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'baz',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
done(
|
|
|
|
'Expected to throw error when alias has missing parent, got ' +
|
|
|
|
JSON.stringify(result)
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'baz',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Invalid parent, 2 levels, reverse order', (done) => {
|
2021-05-24 10:25:02 +00:00
|
|
|
try {
|
|
|
|
const result = validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'baz2',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
done(
|
|
|
|
'Expected to throw error when alias has missing parent, got ' +
|
|
|
|
JSON.stringify(result)
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'baz2',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'missing',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2021-09-20 20:53:49 +00:00
|
|
|
test('Parent loop', (done) => {
|
2021-05-24 10:25:02 +00:00
|
|
|
try {
|
|
|
|
const result = validateIconSet({
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'baz2',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'baz',
|
|
|
|
},
|
|
|
|
baz3: {
|
|
|
|
parent: 'bar',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
done(
|
|
|
|
'Expected to throw error when alias has missing parent, got ' +
|
|
|
|
JSON.stringify(result)
|
|
|
|
);
|
|
|
|
} catch (err) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fix it
|
|
|
|
expect(
|
|
|
|
validateIconSet(
|
|
|
|
{
|
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz: {
|
|
|
|
parent: 'baz2',
|
|
|
|
},
|
|
|
|
baz2: {
|
|
|
|
parent: 'baz',
|
|
|
|
},
|
|
|
|
baz3: {
|
|
|
|
parent: 'bar',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ fix: true }
|
|
|
|
)
|
2021-09-20 20:53:49 +00:00
|
|
|
).toEqual({
|
2021-05-24 10:25:02 +00:00
|
|
|
prefix: 'foo',
|
|
|
|
icons: {
|
|
|
|
bar: {
|
|
|
|
body: '<g />',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
aliases: {
|
|
|
|
baz3: {
|
|
|
|
parent: 'bar',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|