Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor integration tests to reflect different import styles
  • Loading branch information
aron committed Jan 13, 2024
commit c907f42751a538c45df4eaf6a54dfcb2639f6f1e
21 changes: 21 additions & 0 deletions integration/commonjs/constructor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { test } = require('node:test');
const assert = require('node:assert');
const Replicate = require('replicate').Replicate;

const replicate = new Replicate();

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Claire CommonJS"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Claire CommonJS");
});
21 changes: 21 additions & 0 deletions integration/commonjs/deprecated.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { test } = require('node:test');
const assert = require('node:assert');
const Replicate = require('replicate');

const replicate = new Replicate();

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Claire CommonJS"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Claire CommonJS");
});
8 changes: 0 additions & 8 deletions integration/commonjs/index.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion integration/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "CommonJS integration tests",
"main": "index.js",
"scripts": {
"test": "node --test ./index.test.js"
"test": "node --test ./*.test.js"
},
"dependencies": {
"replicate": "file:../../"
Expand Down
19 changes: 19 additions & 0 deletions integration/commonjs/singleton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { test } = require('node:test');
const assert = require('node:assert');
const replicate = require('replicate');

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Claire CommonJS"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Claire CommonJS");
});
21 changes: 21 additions & 0 deletions integration/esm/constructor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from 'node:test';
import assert from 'node:assert';
import replicate_ from "replicate";

const replicate = new replicate_.Replicate();

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Evelyn ESM"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Evelyn ESM");
});
13 changes: 9 additions & 4 deletions integration/esm/index.js → integration/esm/deprecated.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test } from 'node:test';
import assert from 'node:assert';
import Replicate from "replicate";

const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
const replicate = new Replicate();

export default async function main() {
async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
Expand All @@ -14,3 +14,8 @@ export default async function main() {
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Evelyn ESM");
});
8 changes: 0 additions & 8 deletions integration/esm/index.test.js

This file was deleted.

2 changes: 1 addition & 1 deletion integration/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"test": "node --test ./index.test.js"
"test": "node --test ./*.test.js"
},
"dependencies": {
"replicate": "file:../../"
Expand Down
19 changes: 19 additions & 0 deletions integration/esm/singleton.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test } from 'node:test';
import assert from 'node:assert';
import replicate from "replicate";

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Evelyn ESM"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Evelyn ESM");
});
21 changes: 21 additions & 0 deletions integration/typescript/constructor.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from 'node:test';
import assert from 'node:assert';
import replicate_ from "replicate";

const replicate = new replicate_.Replicate();

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Tracy TypeScript"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Tracy TypeScript");
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test } from 'node:test';
import assert from 'node:assert';
import Replicate from "replicate";

const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
const replicate = new Replicate();

export default async function main() {
async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
Expand All @@ -14,3 +14,8 @@ export default async function main() {
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Tracy TypeScript");
});
24 changes: 0 additions & 24 deletions integration/typescript/index.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion integration/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"test": "tsc && node --test ./dist/index.test.js"
"test": "tsc && node --test ./dist/*.test.js"
},
"dependencies": {
"@types/node": "^20.11.0",
Expand Down
19 changes: 19 additions & 0 deletions integration/typescript/singleton.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { test } from 'node:test';
import assert from 'node:assert';
import replicate from "replicate";

async function main() {
return await replicate.run(
"replicate/hello-world:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa",
{
input: {
text: "Tracy TypeScript"
}
}
);
};

test('main', async () => {
const output = await main();
assert.equal(output, "hello Tracy TypeScript");
});