Skip to content

Commit 95a5cce

Browse files
test: dev container
1 parent fda5780 commit 95a5cce

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

plugins/plugin-tools/src/config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ export const readJunoConfig = async ({mode}: ConfigArgs): Promise<JunoConfig> =>
9797
export const assertJunoConfig = async () => {
9898
const exist = await junoConfigExistTools(JUNO_CONFIG_FILE);
9999

100-
console.log(exist);
101-
102100
if (!exist) {
103101
throw new JunoPluginError(
104102
`No Juno configuration found. Run "juno init" to configure your dapp.`

plugins/plugin-tools/src/init.spec.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ vi.mock('@junobuild/config-loader', async () => {
1919
describe('init', () => {
2020
const args: ConfigArgs = {
2121
params: {},
22-
mode: 'development'
22+
mode: 'production'
2323
};
2424

2525
let spyJunoConfigExist: MockInstance;
@@ -30,13 +30,16 @@ describe('init', () => {
3030

3131
spyJunoConfigExist = vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(true);
3232
spyReadJunoConfig = vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValue({
33-
satellite: {ids: {development: 'mock-satellite-id'}},
33+
satellite: {ids: {production: 'mock-satellite-id'}},
3434
orbiter: {id: 'mock-orbiter-id'}
3535
});
3636
});
3737

38-
it('returns config', async () => {
39-
const result = await initConfig(args);
38+
it('returns config for development', async () => {
39+
const result = await initConfig({
40+
params: {},
41+
mode: 'development'
42+
});
4043

4144
expect(result).toEqual({
4245
orbiterId: undefined,
@@ -54,10 +57,7 @@ describe('init', () => {
5457
});
5558

5659
it('returns config without container for production', async () => {
57-
const result = await initConfig({
58-
...args,
59-
mode: 'production'
60-
});
60+
const result = await initConfig(args);
6161

6262
expect(result).toEqual({
6363
satelliteId: 'mock-satellite-id',
@@ -97,17 +97,34 @@ describe('init', () => {
9797
expect(spyReadJunoConfig).not.toHaveBeenCalled();
9898
});
9999

100-
it('throws if config does not exist', async () => {
100+
it('throws if config does not exist and mode is production', async () => {
101101
vi.spyOn(configLoader, 'junoConfigExist').mockResolvedValue(false);
102102

103103
await expect(initConfig(args)).rejects.toThrow(/No Juno configuration found/);
104104
});
105105

106+
it('throws if satelliteId is missing in config if container is set to false', async () => {
107+
vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValueOnce({
108+
satellite: {}
109+
} as unknown as JunoConfig);
110+
111+
await expect(
112+
initConfig({
113+
params: {
114+
container: false
115+
},
116+
mode: 'development'
117+
})
118+
).rejects.toThrow(/A satellite ID for development must be set/);
119+
});
120+
106121
it('throws if satelliteId is missing in config', async () => {
107122
vi.spyOn(configLoader, 'readJunoConfig').mockResolvedValueOnce({
108123
satellite: {}
109124
} as unknown as JunoConfig);
110125

111-
await expect(initConfig(args)).rejects.toThrow(/A satellite ID for development must be set/);
126+
await expect(initConfig(args)).rejects.toThrow(
127+
/Your configuration is invalid. A satellite ID for production must be set in your configuration file./
128+
);
112129
});
113130
});

0 commit comments

Comments
 (0)