Skip to content

Commit

Permalink
Cleanup and renaming tests
Browse files Browse the repository at this point in the history
  • Loading branch information
technoplato committed Mar 26, 2024
1 parent 1825938 commit be20ca0
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions libs/permissions/permissionLogic/src/lib/permission-logic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import {
ActorRef,
InspectionEvent,
Snapshot,
assertEvent,
assign,
Expand All @@ -14,14 +15,8 @@ import {
sendTo,
setup,
waitFor,
InspectionEvent,
} from 'xstate';

import {
createWebSocketInspector,
createSkyInspector,
} from '@statelyai/inspect';

import { unimplementedPermissionMachineActions } from './permission.actions';
import {
InitialPermissionStatusMap,
Expand Down Expand Up @@ -68,7 +63,7 @@ describe('permission requester and checker machine', () => {
};
};

it('should report permission to parent after a check', async () => {
it('handle the happy path of being invoked, checking permission initially and then handle a permission request', async () => {
const stubApplicationLifecycleReportingMachine =
// TODO figure out how to type what events this sends back
fromCallback(({ sendBack }) => {
Expand Down Expand Up @@ -125,6 +120,7 @@ describe('permission requester and checker machine', () => {
}),
},
}).createMachine({
/** @xstate-layout N4IgpgJg5mDOIC5QCMCWUDSBDAFgVwDssA6LABzIBtUBjLAF1QHsCAZVAMzBoE8bKwAYnJVaDZgQBiTAE5goMpoQiQA2gAYAuolBkmsVIxY6QAD0QBaAKxWA7MQAcAJgCcrpwDYnVgIx2ALAA0IDyITupOxOrqAMzhDg4xDuq2Pn4AvunBaJi4hCQi1HRGbJzcfALCFEXiLABCWDQA1gpKBCoQGtpIIHoGJSbmCNZWLsSjHg62Vh4xLlNuwaEIMT4OxD5Oqf4+-up2sR6Z2ejY+ETEZGAyALaosAYssMKUlAAK13cPErAAwjjcJpqLQmPqGCSDRAxfyRdQwhIeHZWGJw-ZLSxrdQbWa2Wxw-wuabRJzHEA5M75S6fe6PAjPegydAwGQfW40iT-QFdUH6cHGHpDCz+DzEHbqPxzTzOGK2FwedHDHwuGKi1LqBw7DUeKz7Byk8l5C5XNnfJ6CBlM66sr60gBKYAAjng4PRuT0wQMBWFYepJoTJg55jDvAroZEZbinKs4lGPEcsmTToaSMabT9BKn2Sx7U6XcDurpeZ7QEMZVi-C4CbqnA4fOoXKHJo4YtDAy2ptCrJkEwQmCp4D0DecsDz+hCvcNtVZxnKpjM5gsnAqLDWsbK5oTwr7ov59Unh6RqmISuwuLx+GBR3yCJDJykZ5NprN5rKlyEoSqvC3prYnE4fC2UZ7rkB6FMeEinuUF6HqIxQSAAkrA8FSLI8iKMoV7FmYlg1tOzgRNqeK+g4iIxAqPgePYuJ2FsexuB4mzARSFxgXBLCQeeAgwTUJTIchDTNK0GHukW44ljhCRRP4MQzFMsTOFGoY+FRLi+OKJG2Axti7gmQ6Upmpp0phYnYQgzhREkDhWM4-i1rMMKhvYslKuKLb+EiLjdukQA */
id: 'bigKahuna',
type: 'parallel',

Expand Down Expand Up @@ -171,23 +167,14 @@ describe('permission requester and checker machine', () => {
triggerPermissionRequest: {
actions: [
log('triggering permission request'),
// () => {
// console.log('triggering permission request');
// },
sendTo('someFooMachine', ({ context, event }) => {
assertEvent(event, 'triggerPermissionRequest');
console.log({ event });

return {
type: 'triggerPermissionRequest',
permission: event.permission,
};
}),
// sendTo('someFooMachine', {
// type: 'triggerPermissionRequest',
// // intentionally incorrect because I need to pick this from event
// permission: Permissions.bluetooth,
// }),
],
},

Expand Down Expand Up @@ -423,7 +410,7 @@ const permissionCheckerAndRequesterMachine = setup({
},
events: {} as PermissionMachineEvents,
input: {} as {
parent: ActorRef<Snapshot<unknown>, ParentEvent>;
parent?: ActorRef<Snapshot<unknown>, ParentEvent>;
},
},

Expand Down

0 comments on commit be20ca0

Please sign in to comment.