update versions

This commit is contained in:
2026-02-16 10:48:25 -08:00
parent 3f8c930d48
commit ee78f04d33
3 changed files with 185 additions and 354 deletions
+2 -1
View File
@@ -11,4 +11,5 @@ environment:
dev_dependencies: dev_dependencies:
lints: ^6.0.0 lints: ^6.0.0
test: ^1.29.0 flutter_test:
sdk: flutter
+175 -177
View File
@@ -1,197 +1,195 @@
import 'dart:async'; import 'package:flutter_test/flutter_test.dart';
import 'package:test/test.dart';
import 'package:undo/undo.dart'; import 'package:undo/undo.dart';
void main() { void main() {
group('initial state', () { group('initial state', () {
test('is correct', () { test('is correct', () {
final states = <int>[]; final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add); final testObject = SimpleStack(0, onUpdate: states.add);
expect(testObject.state, 0); expect(testObject.state, 0);
}); });
});
group('canUndo', () {
test('is false when no state changes have occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
expect(testObject.canUndo, isFalse);
}); });
group('canUndo', () { test('is true when a single state change has occurred', () async {
test('is false when no state changes have occurred', () async { final states = <int>[];
final states = <int>[]; final testObject = SimpleStack(0, onUpdate: states.add);
final testObject = SimpleStack(0, onUpdate: states.add); await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
expect(testObject.canUndo, isFalse); expect(testObject.canUndo, isTrue);
});
test('is true when a single state change has occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
expect(testObject.canUndo, isTrue);
});
test('is false when undos have been exhausted', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(testObject.canUndo, isFalse);
});
}); });
group('canRedo', () { test('is false when undos have been exhausted', () async {
test('is false when no state changes have occurred', () async { final states = <int>[];
final states = <int>[]; final testObject = SimpleStack(0, onUpdate: states.add);
final testObject = SimpleStack(0, onUpdate: states.add); await Future<void>.delayed(
expect(testObject.canRedo, isFalse); Duration.zero, () => testObject.modify(testObject.state + 1));
}); await Future<void>.delayed(Duration.zero, testObject.undo);
test('is true when a single undo has occurred', () async { expect(testObject.canUndo, isFalse);
final states = <int>[]; });
final testObject = SimpleStack(0, onUpdate: states.add); });
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(testObject.canRedo, isTrue);
});
test('is false when redos have been exhausted', () async { group('canRedo', () {
final states = <int>[]; test('is false when no state changes have occurred', () async {
final testObject = SimpleStack(0, onUpdate: states.add); final states = <int>[];
await Future<void>.delayed( final testObject = SimpleStack(0, onUpdate: states.add);
Duration.zero, () => testObject.modify(testObject.state + 1)); expect(testObject.canRedo, isFalse);
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(testObject.canRedo, isFalse);
});
}); });
group('clearHistory', () { test('is true when a single undo has occurred', () async {
test('clears history and redos on new testObject', () async { final states = <int>[];
final testObject = SimpleStack(0)..clearHistory(); final testObject = SimpleStack(0, onUpdate: states.add);
expect(testObject.canRedo, isFalse); await Future<void>.delayed(
expect(testObject.canUndo, isFalse); Duration.zero, () => testObject.modify(testObject.state + 1));
}); await Future<void>.delayed(Duration.zero, testObject.undo);
expect(testObject.canRedo, isTrue);
}); });
group('undo', () { test('is false when redos have been exhausted', () async {
test('does nothing when no state changes have occurred', () async { final states = <int>[];
final states = <int>[]; final testObject = SimpleStack(0, onUpdate: states.add);
final testObject = SimpleStack(0, onUpdate: states.add); await Future<void>.delayed(
await Future<void>.delayed(Duration.zero, testObject.undo); Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(testObject.canRedo, isFalse);
});
});
expect(states, [0]); group('clearHistory', () {
}); test('clears history and redos on new testObject', () async {
final testObject = SimpleStack(0)..clearHistory();
expect(testObject.canRedo, isFalse);
expect(testObject.canUndo, isFalse);
});
});
test('does nothing when limit is 0', () async { group('undo', () {
final states = <int>[]; test('does nothing when no state changes have occurred', () async {
final testObject = SimpleStack(0, limit: 0, onUpdate: states.add); final states = <int>[];
await Future<void>.delayed( final testObject = SimpleStack(0, onUpdate: states.add);
Duration.zero, () => testObject.modify(testObject.state + 1)); await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 0]); expect(states, [0]);
});
test('loses history outside of limit', () async {
final states = <int>[];
final testObject = SimpleStack(0, limit: 1, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 2, 1, 0]);
});
test('reverts to initial state', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 0]);
});
test('reverts to previous state with multiple state changes ', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 2, 1]);
});
}); });
group('redo', () { test('does nothing when limit is 0', () async {
test('does nothing when no state changes have occurred', () async { final states = <int>[];
final states = <int>[]; final testObject = SimpleStack(0, limit: 0, onUpdate: states.add);
final testObject = SimpleStack(0, onUpdate: states.add); await Future<void>.delayed(
await Future<void>.delayed(Duration.zero, testObject.redo); Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0]); expect(states, [0, 1, 0]);
});
test('does nothing when no undos have occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2]);
});
test('works when one undo has occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 2]);
});
test('does nothing when undos have been exhausted', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 2]);
});
test(
'does nothing when undos has occurred '
'followed by a new state change', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state - 1));
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 0]);
});
}); });
}
test('loses history outside of limit', () async {
final states = <int>[];
final testObject = SimpleStack(0, limit: 1, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 2, 1, 0]);
});
test('reverts to initial state', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 0]);
});
test('reverts to previous state with multiple state changes ', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
expect(states, [0, 1, 2, 1]);
});
});
group('redo', () {
test('does nothing when no state changes have occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0]);
});
test('does nothing when no undos have occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2]);
});
test('works when one undo has occurred', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 2]);
});
test('does nothing when undos have been exhausted', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(Duration.zero, testObject.redo);
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 2]);
});
test(
'does nothing when undos has occurred '
'followed by a new state change', () async {
final states = <int>[];
final testObject = SimpleStack(0, onUpdate: states.add);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state + 1));
await Future<void>.delayed(Duration.zero, testObject.undo);
await Future<void>.delayed(
Duration.zero, () => testObject.modify(testObject.state - 1));
await Future<void>.delayed(Duration.zero, testObject.redo);
expect(states, [0, 1, 2, 1, 0]);
});
});
}
+8 -176
View File
@@ -61,18 +61,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.4.1" version: "1.4.0"
cli_config:
dependency: transitive
description:
name: cli_config
sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
url: "https://pub.dev"
source: hosted
version: "0.2.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@@ -105,14 +97,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.2" version: "3.1.2"
coverage:
dependency: transitive
description:
name: coverage
sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d"
url: "https://pub.dev"
source: hosted
version: "1.15.0"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@@ -192,14 +176,6 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
url: "https://pub.dev"
source: hosted
version: "4.0.0"
glob: glob:
dependency: transitive dependency: transitive
description: description:
@@ -216,30 +192,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.2" version: "2.3.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8
url: "https://pub.dev"
source: hosted
version: "3.2.2"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
url: "https://pub.dev"
source: hosted
version: "4.1.2"
io:
dependency: transitive
description:
name: io
sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b
url: "https://pub.dev"
source: hosted
version: "1.0.5"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
@@ -272,14 +224,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.0" version: "6.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
url: "https://pub.dev"
source: hosted
version: "1.3.0"
markdown: markdown:
dependency: transitive dependency: transitive
description: description:
@@ -292,18 +236,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.18" version: "0.12.17"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.13.0" version: "0.11.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -312,22 +256,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.0"
mime:
dependency: transitive
description:
name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@@ -392,14 +320,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.8" version: "2.1.8"
pool:
dependency: transitive
description:
name: pool
sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d"
url: "https://pub.dev"
source: hosted
version: "1.5.2"
pub_semver: pub_semver:
dependency: transitive dependency: transitive
description: description:
@@ -464,59 +384,11 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.1" version: "2.4.1"
shelf:
dependency: transitive
description:
name: shelf
sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
url: "https://pub.dev"
source: hosted
version: "1.4.2"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
url: "https://pub.dev"
source: hosted
version: "1.1.3"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
url: "https://pub.dev"
source: hosted
version: "2.1.2"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812"
url: "https://pub.dev"
source: hosted
version: "0.10.13"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@@ -557,30 +429,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.2" version: "1.2.2"
test:
dependency: transitive
description:
name: test
sha256: "54c516bbb7cee2754d327ad4fca637f78abfc3cbcc5ace83b3eda117e42cd71a"
url: "https://pub.dev"
source: hosted
version: "1.29.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.9" version: "0.7.7"
test_core:
dependency: transitive
description:
name: test_core
sha256: "394f07d21f0f2255ec9e3989f21e54d3c7dc0e6e9dbce160e5a9c1a6be0e2943"
url: "https://pub.dev"
source: hosted
version: "0.6.15"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -685,30 +541,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"
url: "https://pub.dev"
source: hosted
version: "1.0.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
url: "https://pub.dev"
source: hosted
version: "3.0.3"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description: