Skip to content

Commit 1d70bb6

Browse files
committed
cleanup: old tests
1 parent cadfbc7 commit 1d70bb6

File tree

2 files changed

+0
-324
lines changed

2 files changed

+0
-324
lines changed

app-config-extensions/src/env-var-directive.test.ts

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -95,86 +95,6 @@ describe('$envVar directive', () => {
9595
expect(parsed.toJSON()).toEqual({ foo: null, bar: 'foo' });
9696
});
9797

98-
it('parses ints', async () => {
99-
process.env.FOO = '11';
100-
101-
const source = new LiteralSource({
102-
$envVar: { name: 'FOO', parseInt: true },
103-
});
104-
105-
expect(await source.readToJSON([envVarDirective()])).toEqual(11);
106-
});
107-
108-
it('fails when int is invalid', async () => {
109-
process.env.FOO = 'not a number';
110-
111-
const source = new LiteralSource({
112-
$envVar: { name: 'FOO', parseInt: true },
113-
});
114-
115-
await expect(source.read([envVarDirective()])).rejects.toThrow();
116-
});
117-
118-
it('parses float', async () => {
119-
process.env.FOO = '11.2';
120-
121-
const source = new LiteralSource({
122-
$envVar: { name: 'FOO', parseFloat: true },
123-
});
124-
125-
expect(await source.readToJSON([envVarDirective()])).toEqual(11.2);
126-
});
127-
128-
it('fails when float is invalid', async () => {
129-
process.env.FOO = 'not a number';
130-
131-
const source = new LiteralSource({
132-
$envVar: { name: 'FOO', parseFloat: true },
133-
});
134-
135-
await expect(source.read([envVarDirective()])).rejects.toThrow();
136-
});
137-
138-
it('parses boolean = true', async () => {
139-
process.env.FOO = 'true';
140-
141-
const source = new LiteralSource({
142-
$envVar: { name: 'FOO', parseBool: true },
143-
});
144-
145-
expect(await source.readToJSON([envVarDirective()])).toEqual(true);
146-
});
147-
148-
it('parses boolean = 1', async () => {
149-
process.env.FOO = '1';
150-
151-
const source = new LiteralSource({
152-
$envVar: { name: 'FOO', parseBool: true },
153-
});
154-
155-
expect(await source.readToJSON([envVarDirective()])).toEqual(true);
156-
});
157-
158-
it('parses boolean = 0', async () => {
159-
process.env.FOO = '0';
160-
161-
const source = new LiteralSource({
162-
$envVar: { name: 'FOO', parseBool: true },
163-
});
164-
165-
expect(await source.readToJSON([envVarDirective()])).toEqual(false);
166-
});
167-
168-
it('parses boolean = false', async () => {
169-
process.env.FOO = 'false';
170-
171-
const source = new LiteralSource({
172-
$envVar: { name: 'FOO', parseBool: true },
173-
});
174-
175-
expect(await source.readToJSON([envVarDirective()])).toEqual(false);
176-
});
177-
17898
it('doesnt visit fallback if name is defined', async () => {
17999
const failDirective = forKey('$fail', () => () => {
180100
throw new Error();
@@ -202,12 +122,4 @@ describe('$envVar directive', () => {
202122

203123
expect(parsed.toJSON()).toEqual({ foo: 'qa' });
204124
});
205-
206-
it('parses boolean from fallback', async () => {
207-
const source = new LiteralSource({
208-
$envVar: { name: 'FOO', parseBool: true, fallback: 'true' },
209-
});
210-
211-
expect(await source.readToJSON([envVarDirective()])).toEqual(true);
212-
});
213125
});

app-config-extensions/src/substitute-directive.test.ts

Lines changed: 0 additions & 236 deletions
Original file line numberDiff line numberDiff line change
@@ -152,162 +152,6 @@ describe('$substitute directive', () => {
152152
expect(parsed.toJSON()).toEqual({ foo: 'qa' });
153153
});
154154

155-
it('reads object with $name', async () => {
156-
process.env.FOO = 'foo';
157-
158-
const source = new LiteralSource({
159-
foo: { $substitute: { $name: 'FOO' } },
160-
});
161-
162-
const parsed = await source.read([substituteDirective()]);
163-
164-
expect(parsed.toJSON()).toEqual({ foo: 'foo' });
165-
});
166-
167-
it('fails with $name when not defined', async () => {
168-
const source = new LiteralSource({
169-
foo: { $substitute: { $name: 'FOO' } },
170-
});
171-
172-
await expect(source.read([substituteDirective()])).rejects.toThrow();
173-
});
174-
175-
it('uses $name when $fallback is defined', async () => {
176-
process.env.FOO = 'foo';
177-
178-
const source = new LiteralSource({
179-
foo: { $substitute: { $name: 'FOO', $fallback: 'bar' } },
180-
});
181-
182-
const parsed = await source.read([substituteDirective()]);
183-
184-
expect(parsed.toJSON()).toEqual({ foo: 'foo' });
185-
});
186-
187-
it('uses $fallback when $name was not found', async () => {
188-
const source = new LiteralSource({
189-
foo: { $substitute: { $name: 'FOO', $fallback: 'bar' } },
190-
});
191-
192-
const parsed = await source.read([substituteDirective()]);
193-
194-
expect(parsed.toJSON()).toEqual({ foo: 'bar' });
195-
});
196-
197-
it('allows null value when $allowNull', async () => {
198-
const source = new LiteralSource({
199-
foo: { $substitute: { $name: 'FOO', $fallback: null, $allowNull: true } },
200-
});
201-
202-
const parsed = await source.read([substituteDirective()]);
203-
204-
expect(parsed.toJSON()).toEqual({ foo: null });
205-
});
206-
207-
it('does not allow number even when $allowNull', async () => {
208-
const source = new LiteralSource({
209-
foo: { $substitute: { $name: 'FOO', $fallback: 42, $allowNull: true } },
210-
});
211-
212-
await expect(source.read([substituteDirective()])).rejects.toThrow();
213-
});
214-
215-
it('parses ints', async () => {
216-
process.env.FOO = '11';
217-
218-
const source = new LiteralSource({
219-
$substitute: { $name: 'FOO', $parseInt: true },
220-
});
221-
222-
expect(await source.readToJSON([substituteDirective()])).toEqual(11);
223-
});
224-
225-
it('fails when int is invalid', async () => {
226-
process.env.FOO = 'not a number';
227-
228-
const source = new LiteralSource({
229-
$substitute: { $name: 'FOO', $parseInt: true },
230-
});
231-
232-
await expect(source.read([substituteDirective()])).rejects.toThrow();
233-
});
234-
235-
it('parses float', async () => {
236-
process.env.FOO = '11.2';
237-
238-
const source = new LiteralSource({
239-
$substitute: { $name: 'FOO', $parseFloat: true },
240-
});
241-
242-
expect(await source.readToJSON([substituteDirective()])).toEqual(11.2);
243-
});
244-
245-
it('fails when float is invalid', async () => {
246-
process.env.FOO = 'not a number';
247-
248-
const source = new LiteralSource({
249-
$substitute: { $name: 'FOO', $parseFloat: true },
250-
});
251-
252-
await expect(source.read([substituteDirective()])).rejects.toThrow();
253-
});
254-
255-
it('parses boolean = true', async () => {
256-
process.env.FOO = 'true';
257-
258-
const source = new LiteralSource({
259-
$substitute: { $name: 'FOO', $parseBool: true },
260-
});
261-
262-
expect(await source.readToJSON([substituteDirective()])).toEqual(true);
263-
});
264-
265-
it('parses boolean = 1', async () => {
266-
process.env.FOO = '1';
267-
268-
const source = new LiteralSource({
269-
$substitute: { $name: 'FOO', $parseBool: true },
270-
});
271-
272-
expect(await source.readToJSON([substituteDirective()])).toEqual(true);
273-
});
274-
275-
it('parses boolean = 0', async () => {
276-
process.env.FOO = '0';
277-
278-
const source = new LiteralSource({
279-
$substitute: { $name: 'FOO', $parseBool: true },
280-
});
281-
282-
expect(await source.readToJSON([substituteDirective()])).toEqual(false);
283-
});
284-
285-
it('parses boolean = false', async () => {
286-
process.env.FOO = 'false';
287-
288-
const source = new LiteralSource({
289-
$substitute: { $name: 'FOO', $parseBool: true },
290-
});
291-
292-
expect(await source.readToJSON([substituteDirective()])).toEqual(false);
293-
});
294-
295-
it('doesnt visit fallback if name is defined', async () => {
296-
const failDirective = forKey('$fail', () => () => {
297-
throw new Error();
298-
});
299-
300-
process.env.FOO = 'foo';
301-
302-
const source = new LiteralSource({
303-
foo: { $substitute: { $name: 'FOO', $fallback: { $fail: true } } },
304-
});
305-
306-
const parsed = await source.read([substituteDirective(), failDirective]);
307-
308-
expect(parsed.toJSON()).toEqual({ foo: 'foo' });
309-
});
310-
311155
it('reads object with name', async () => {
312156
process.env.FOO = 'foo';
313157

@@ -368,86 +212,6 @@ describe('$substitute directive', () => {
368212
await expect(source.read([substituteDirective()])).rejects.toThrow();
369213
});
370214

371-
it('parses ints', async () => {
372-
process.env.FOO = '11';
373-
374-
const source = new LiteralSource({
375-
$substitute: { name: 'FOO', parseInt: true },
376-
});
377-
378-
expect(await source.readToJSON([substituteDirective()])).toEqual(11);
379-
});
380-
381-
it('fails when int is invalid', async () => {
382-
process.env.FOO = 'not a number';
383-
384-
const source = new LiteralSource({
385-
$substitute: { name: 'FOO', parseInt: true },
386-
});
387-
388-
await expect(source.read([substituteDirective()])).rejects.toThrow();
389-
});
390-
391-
it('parses float', async () => {
392-
process.env.FOO = '11.2';
393-
394-
const source = new LiteralSource({
395-
$substitute: { name: 'FOO', parseFloat: true },
396-
});
397-
398-
expect(await source.readToJSON([substituteDirective()])).toEqual(11.2);
399-
});
400-
401-
it('fails when float is invalid', async () => {
402-
process.env.FOO = 'not a number';
403-
404-
const source = new LiteralSource({
405-
$substitute: { name: 'FOO', parseFloat: true },
406-
});
407-
408-
await expect(source.read([substituteDirective()])).rejects.toThrow();
409-
});
410-
411-
it('parses boolean = true', async () => {
412-
process.env.FOO = 'true';
413-
414-
const source = new LiteralSource({
415-
$substitute: { name: 'FOO', parseBool: true },
416-
});
417-
418-
expect(await source.readToJSON([substituteDirective()])).toEqual(true);
419-
});
420-
421-
it('parses boolean = 1', async () => {
422-
process.env.FOO = '1';
423-
424-
const source = new LiteralSource({
425-
$substitute: { name: 'FOO', parseBool: true },
426-
});
427-
428-
expect(await source.readToJSON([substituteDirective()])).toEqual(true);
429-
});
430-
431-
it('parses boolean = 0', async () => {
432-
process.env.FOO = '0';
433-
434-
const source = new LiteralSource({
435-
$substitute: { name: 'FOO', parseBool: true },
436-
});
437-
438-
expect(await source.readToJSON([substituteDirective()])).toEqual(false);
439-
});
440-
441-
it('parses boolean = false', async () => {
442-
process.env.FOO = 'false';
443-
444-
const source = new LiteralSource({
445-
$substitute: { name: 'FOO', parseBool: true },
446-
});
447-
448-
expect(await source.readToJSON([substituteDirective()])).toEqual(false);
449-
});
450-
451215
it('doesnt visit fallback if name is defined', async () => {
452216
const failDirective = forKey('$fail', () => () => {
453217
throw new Error();

0 commit comments

Comments
 (0)