Skip to content

Commit

Permalink
Add a bunch of expandSeedPacket tests.
Browse files Browse the repository at this point in the history
One doesn't yet pass so commented out.

Part of #2.
  • Loading branch information
jkomoros committed Jun 25, 2023
1 parent df9725b commit b21a9d4
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions test/base/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
import {
makeAbsolute
} from '../../src/reference.js';
import { expandSeedPacket } from '../../src/seed.js';

import {
AbsoluteSeedReference,
EnvironmentData,
ExpandedSeedPacket,
SeedReference,
seedID,
seedPacket,
Expand Down Expand Up @@ -246,6 +248,122 @@ describe('Garden smoke test', () => {
//TODO: a named inner value doesn't pass.
});

describe('expandSeedPacket tests', () => {
it('no op', async () => {
const packet = seedPacket.parse({
version: 0,
seeds: {}
});
const result = expandSeedPacket(packet);
const golden : ExpandedSeedPacket = {
version: 0,
seeds: {}
};
assert.deepStrictEqual(result, golden);
});

it('basic non-nested', async () => {
const packet = seedPacket.parse({
version: 0,
seeds: {
'': {
'type': 'log',
'value': {
'id': 'other'
}
},
'other': {
'type': 'log',
'value': true
}
}
});
const result = expandSeedPacket(packet);
const golden : ExpandedSeedPacket = {
version: 0,
seeds: {
'': {
'type': 'log',
'value': {
'id': 'other'
}
},
'other': {
'type': 'log',
'value': true
}
}
};
assert.deepStrictEqual(result, golden);
});

it('basic nested', async () => {
const packet = seedPacket.parse({
version: 0,
seeds: {
'': {
'type': 'log',
'value': {
'type': 'log',
'value': true
}
}
}
});
const result = expandSeedPacket(packet);
const golden : ExpandedSeedPacket = {
version: 0,
seeds: {
'': {
'type': 'log',
'value': {
'id': '-value'
}
},
'-value': {
'type': 'log',
'value': true
}
}
};
assert.deepStrictEqual(result, golden);
});

//TODO: enable this test (currently fails)
// it('basic named nested', async () => {
// const packet = seedPacket.parse({
// version: 0,
// seeds: {
// '': {
// 'type': 'log',
// 'value': {
// 'id': 'foo',
// 'type': 'log',
// 'value': true
// }
// }
// }
// });
// const result = expandSeedPacket(packet);
// const golden : ExpandedSeedPacket = {
// version: 0,
// seeds: {
// '': {
// 'type': 'log',
// 'value': {
// 'id': 'foo'
// }
// },
// 'foo': {
// 'type': 'log',
// 'value': true
// }
// }
// };
// assert.deepStrictEqual(result, golden);
// });
});


describe('reference regexp tests', () => {
it('basic local seed reference empty', async() => {
Expand Down

0 comments on commit b21a9d4

Please sign in to comment.