Skip to content

Commit c907f42

Browse files
committed
Refactor integration tests to reflect different import styles
1 parent f16e7d9 commit c907f42

15 files changed

+162
-51
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { test } = require('node:test');
2+
const assert = require('node:assert');
3+
const Replicate = require('replicate').Replicate;
4+
5+
const replicate = new Replicate();
6+
7+
async function main() {
8+
return await replicate.run(
9+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
10+
{
11+
input: {
12+
text: "Claire CommonJS"
13+
}
14+
}
15+
);
16+
};
17+
18+
test('main', async () => {
19+
const output = await main();
20+
assert.equal(output, "hello Claire CommonJS");
21+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { test } = require('node:test');
2+
const assert = require('node:assert');
3+
const Replicate = require('replicate');
4+
5+
const replicate = new Replicate();
6+
7+
async function main() {
8+
return await replicate.run(
9+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
10+
{
11+
input: {
12+
text: "Claire CommonJS"
13+
}
14+
}
15+
);
16+
};
17+
18+
test('main', async () => {
19+
const output = await main();
20+
assert.equal(output, "hello Claire CommonJS");
21+
});

integration/commonjs/index.test.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

integration/commonjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "CommonJS integration tests",
66
"main": "index.js",
77
"scripts": {
8-
"test": "node --test ./index.test.js"
8+
"test": "node --test ./*.test.js"
99
},
1010
"dependencies": {
1111
"replicate": "file:../../"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { test } = require('node:test');
2+
const assert = require('node:assert');
3+
const replicate = require('replicate');
4+
5+
async function main() {
6+
return await replicate.run(
7+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
{
9+
input: {
10+
text: "Claire CommonJS"
11+
}
12+
}
13+
);
14+
};
15+
16+
test('main', async () => {
17+
const output = await main();
18+
assert.equal(output, "hello Claire CommonJS");
19+
});

integration/esm/constructor.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { test } from 'node:test';
2+
import assert from 'node:assert';
3+
import replicate_ from "replicate";
4+
5+
const replicate = new replicate_.Replicate();
6+
7+
async function main() {
8+
return await replicate.run(
9+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
10+
{
11+
input: {
12+
text: "Evelyn ESM"
13+
}
14+
}
15+
);
16+
};
17+
18+
test('main', async () => {
19+
const output = await main();
20+
assert.equal(output, "hello Evelyn ESM");
21+
});
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { test } from 'node:test';
2+
import assert from 'node:assert';
13
import Replicate from "replicate";
24

3-
const replicate = new Replicate({
4-
auth: process.env.REPLICATE_API_TOKEN,
5-
});
5+
const replicate = new Replicate();
66

7-
export default async function main() {
7+
async function main() {
88
return await replicate.run(
99
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
1010
{
@@ -14,3 +14,8 @@ export default async function main() {
1414
}
1515
);
1616
};
17+
18+
test('main', async () => {
19+
const output = await main();
20+
assert.equal(output, "hello Evelyn ESM");
21+
});

integration/esm/index.test.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

integration/esm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "index.js",
77
"type": "module",
88
"scripts": {
9-
"test": "node --test ./index.test.js"
9+
"test": "node --test ./*.test.js"
1010
},
1111
"dependencies": {
1212
"replicate": "file:../../"

integration/esm/singleton.test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test } from 'node:test';
2+
import assert from 'node:assert';
3+
import replicate from "replicate";
4+
5+
async function main() {
6+
return await replicate.run(
7+
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
8+
{
9+
input: {
10+
text: "Evelyn ESM"
11+
}
12+
}
13+
);
14+
};
15+
16+
test('main', async () => {
17+
const output = await main();
18+
assert.equal(output, "hello Evelyn ESM");
19+
});

0 commit comments

Comments
 (0)