Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: move project settings tests to node:test #660

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
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
19 changes: 12 additions & 7 deletions test-e2e/project-settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
import { test } from 'brittle'
import test from 'node:test'
import assert from 'node:assert/strict'
import { KeyManager } from '@mapeo/crypto'
import RAM from 'random-access-memory'
import Fastify from 'fastify'
Expand All @@ -8,7 +9,7 @@ import { MapeoManager } from '../src/mapeo-manager.js'
import { MapeoProject } from '../src/mapeo-project.js'
import { removeUndefinedFields } from './utils.js'

test('Project settings create, read, and update operations', async (t) => {
test('Project settings create, read, and update operations', async () => {
const fastify = Fastify()

const manager = new MapeoManager({
Expand All @@ -24,21 +25,21 @@ test('Project settings create, read, and update operations', async (t) => {

const projectId = await manager.createProject()

t.ok(
assert(
projectId && typeof projectId === 'string',
'probably valid project ID returned when creating project'
)

const project = await manager.getProject(projectId)

t.ok(
assert(
project instanceof MapeoProject,
'manager.getProject() returns MapeoProject instance'
)

const initialSettings = await project.$getProjectSettings()

t.alike(
assert.deepEqual(
removeUndefinedFields(initialSettings),
{},
'project has no settings when initially created'
Expand All @@ -50,11 +51,15 @@ test('Project settings create, read, and update operations', async (t) => {

const updatedSettings = await project.$setProjectSettings(expectedSettings)

t.is(updatedSettings.name, expectedSettings.name, 'updatable settings change')
assert.equal(
updatedSettings.name,
expectedSettings.name,
'updatable settings change'
)

const settings = await project.$getProjectSettings()

t.alike(
assert.deepEqual(
settings,
updatedSettings,
'retrieved settings are equivalent to most recently updated'
Expand Down
Loading