mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-02-17 14:30:34 +08:00
feat(build): Added createCheckDuplicateId test.
This commit is contained in:
parent
ed2f983841
commit
414eaa15c1
55
packages/build/src/utils/createCheckDuplicateId.test.js
Normal file
55
packages/build/src/utils/createCheckDuplicateId.test.js
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import createCheckDuplicateId from './createCheckDuplicateId';
|
||||
|
||||
test('checkDuplicateId return value', async () => {
|
||||
const checkDuplicateId = createCheckDuplicateId({
|
||||
message: 'Duplicate id "{{ id }}".',
|
||||
});
|
||||
expect(checkDuplicateId({ id: 'id' })).toBe(undefined);
|
||||
});
|
||||
|
||||
test('throw on duplicate ids', async () => {
|
||||
const checkDuplicateId = createCheckDuplicateId({
|
||||
message: 'Duplicate id "{{ id }}".',
|
||||
});
|
||||
checkDuplicateId({ id: 'id' });
|
||||
checkDuplicateId({ id: 'id_2' });
|
||||
expect(() => checkDuplicateId({ id: 'id' })).toThrow('Duplicate id "id".');
|
||||
});
|
||||
|
||||
test('Error message nunjucks variables', async () => {
|
||||
const checkDuplicateId = createCheckDuplicateId({
|
||||
message: '{{ id }} {{ blockId }} {{ eventId }} {{ menuId }} {{ pageId }}',
|
||||
});
|
||||
checkDuplicateId({
|
||||
id: 'id',
|
||||
blockId: 'blockId',
|
||||
eventId: 'eventId',
|
||||
menuId: 'menuId',
|
||||
pageId: 'pageId',
|
||||
});
|
||||
expect(() =>
|
||||
checkDuplicateId({
|
||||
id: 'id',
|
||||
blockId: 'blockId',
|
||||
eventId: 'eventId',
|
||||
menuId: 'menuId',
|
||||
pageId: 'pageId',
|
||||
})
|
||||
).toThrow('id blockId eventId menuId pageId');
|
||||
});
|
Loading…
Reference in New Issue
Block a user