mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Add a test for the dirty callback on writes
This new test just checks that a clean disk becomes dirty after a write _and_ that the dirty callback is fired.
This commit is contained in:
parent
5b5655b70e
commit
5c9b09a99f
|
@ -499,5 +499,24 @@ describe('DiskII', () => {
|
|||
expect(track0[0]).toBe(0x80);
|
||||
expect(track0[1]).toBe(0x81);
|
||||
});
|
||||
|
||||
it('sets disk state to dirty and calls the dirty callback when written', () => {
|
||||
const diskII = new DiskII(mockApple2IO, callbacks);
|
||||
diskII.setBinary(1, 'BYTES_BY_TRACK', 'po', BYTES_BY_TRACK_IMAGE);
|
||||
let state = diskII.getState();
|
||||
state.drives[0].dirty = false;
|
||||
diskII.setState(state);
|
||||
jest.resetAllMocks();
|
||||
|
||||
diskII.ioSwitch(0x89); // turn on the motor
|
||||
diskII.ioSwitch(0x8F, 0x80); // write
|
||||
diskII.ioSwitch(0x8C); // shift
|
||||
|
||||
expect(callbacks.dirty).toHaveBeenCalledTimes(1);
|
||||
expect(callbacks.dirty).toHaveBeenCalledWith(1, true);
|
||||
|
||||
state = diskII.getState();
|
||||
expect(state.drives[0].dirty).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user