@makakwastaken/ts-edifact
Version:
Edifact parser library
57 lines • 2.26 kB
JavaScript
;
/**
* @author Roman Vottner
* @copyright 2020 Roman Vottner
* @license Apache-2.0
*
* 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.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const configuration_1 = require("../src/configuration");
describe('Configuration', () => {
let configuration;
beforeEach(() => (configuration = new configuration_1.Configuration()));
it('should return the delimiters as a sorted array', () => {
let count = 0;
const run = (permutation) => {
configuration.config.segmentTerminator = permutation[0];
configuration.config.dataElementSeparator = permutation[1];
configuration.config.componentDataSeparator = permutation[2];
configuration.config.decimalMark = permutation[3];
configuration.config.releaseCharacter = permutation[4];
const delimiters = configuration.delimiters();
for (let i = 1; i < delimiters.length; i++) {
expect(delimiters[i]).toBeGreaterThan(delimiters[i - 1]);
}
count++;
};
const permute = (head, tail, callback) => {
if (tail.length === 0) {
callback(head);
}
else {
for (let i = 0; i < tail.length; i++) {
const item = tail[i];
tail.splice(i, 1);
head.push(item);
permute(head, tail, callback);
head.pop();
tail.splice(i, 0, item);
}
}
};
permute([], [0, 1, 2, 3, 4], run);
expect(count).toEqual(120);
});
});
//# sourceMappingURL=configuration.spec.js.map