-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
14,498 additions
and
19,310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.azle | ||
.dfx | ||
dfx_generated | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
{ | ||
"scripts": { | ||
"build": "cd src/frontend && VITE_CANISTER_ORIGIN=http://$(dfx canister id backend).localhost:8000 vite build", | ||
"pretest": "tsx test/pretest.ts", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"azle": "0.23.0", | ||
"express": "^4.18.2", | ||
"lit": "^3.1.2" | ||
"azle": "0.23.0" | ||
}, | ||
"devDependencies": { | ||
"@types/express": "^4.17.21", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.4", | ||
"tsx": "^4.15.7", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.0.12" | ||
"typescript": "^5.2.2" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import { getCanisterId } from 'azle/dfx'; | ||
import { runTests } from 'azle/test'; | ||
|
||
import { createActor } from './dfx_generated/hello_world'; | ||
import { getTests } from './tests'; | ||
|
||
const canisterId = getCanisterId('backend'); | ||
const helloWorldCanister = createActor(getCanisterId('hello_world'), { | ||
agentOptions: { | ||
host: 'http://127.0.0.1:8000' | ||
} | ||
}); | ||
|
||
runTests(getTests(canisterId)); | ||
runTests(getTests(helloWorldCanister)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,28 @@ | ||
import { ActorSubclass } from '@dfinity/agent'; | ||
import { expect, it, Test } from 'azle/test'; | ||
|
||
export function getTests(canisterId: string): Test { | ||
const origin = `http://${canisterId}.localhost:8000`; | ||
// @ts-ignore this path may not exist when these tests are imported into other test projects | ||
import { _SERVICE } from './dfx_generated/hello_world/hello_world.did'; | ||
|
||
export function getTests(helloWorldCanister: ActorSubclass<_SERVICE>): Test { | ||
return () => { | ||
it('gets a simple hello world database', async () => { | ||
const response = await fetch(`${origin}/db`); | ||
const responseJson = await response.json(); | ||
it('gets original message', async () => { | ||
const result = await helloWorldCanister.getMessage(); | ||
|
||
expect(responseJson).toEqual({ hello: '' }); | ||
expect(result).toBe('Hello world!'); | ||
}); | ||
|
||
it('updates a simple hello world database', async () => { | ||
const response = await fetch(`${origin}/db/update`, { | ||
method: 'POST', | ||
headers: [['Content-Type', 'application/json']], | ||
body: JSON.stringify({ | ||
hello: 'world' | ||
}) | ||
}); | ||
const responseJson = await response.json(); | ||
it('sets a new message', async () => { | ||
const result = | ||
await helloWorldCanister.setMessage('Goodbye world!'); | ||
|
||
expect(responseJson).toEqual({ hello: 'world' }); | ||
expect(result).toBeUndefined(); | ||
}); | ||
|
||
it('gets persisted new message', async () => { | ||
const result = await helloWorldCanister.getMessage(); | ||
|
||
expect(result).toBe('Goodbye world!'); | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.