refactor(llc): convert the implementation into non-breaking

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2022-05-19 18:07:22 +05:30
committed by xsahil03x
parent beee0e41c4
commit de3e1c9862
7 changed files with 182 additions and 30 deletions
@@ -55,4 +55,140 @@ void main() {
);
});
});
test('hidden property and extraData manipulation', () {
final channel = ChannelModel(cid: 'test:cid', hidden: false);
expect(channel.hidden, false);
expect(channel.extraData['hidden'], false);
print(channel.toJson());
expect(channel.toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'hidden': false,
});
expect(ChannelModel.fromJson(channel.toJson()).toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'hidden': false,
});
var newChannel = channel.copyWith(
extraData: {'hidden': true},
);
expect(newChannel.extraData['hidden'], true);
expect(newChannel.hidden, true);
newChannel = channel.copyWith(
hidden: false,
);
expect(newChannel.extraData['hidden'], false);
expect(newChannel.hidden, false);
newChannel = channel.copyWith(
hidden: true,
extraData: {'hidden': true},
);
expect(newChannel.extraData['hidden'], true);
expect(newChannel.hidden, true);
});
test('disabled property and extraData manipulation', () {
final channel = ChannelModel(cid: 'test:cid', disabled: false);
expect(channel.disabled, false);
expect(channel.extraData['disabled'], false);
print(channel.toJson());
expect(channel.toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'disabled': false,
});
expect(ChannelModel.fromJson(channel.toJson()).toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'disabled': false,
});
var newChannel = channel.copyWith(
extraData: {'disabled': true},
);
expect(newChannel.extraData['disabled'], true);
expect(newChannel.disabled, true);
newChannel = channel.copyWith(
hidden: false,
);
expect(newChannel.extraData['disabled'], false);
expect(newChannel.disabled, false);
newChannel = channel.copyWith(
hidden: true,
extraData: {'disabled': true},
);
expect(newChannel.extraData['disabled'], true);
expect(newChannel.disabled, true);
});
test('truncatedAt property and extraData manipulation', () {
final currentDate = DateTime.now();
final channel = ChannelModel(cid: 'test:cid', truncatedAt: currentDate);
expect(channel.truncatedAt, currentDate);
expect(channel.extraData['truncated_at'], currentDate.toIso8601String());
print(channel.toJson());
expect(channel.toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'truncated_at': currentDate.toIso8601String(),
});
expect(ChannelModel.fromJson(channel.toJson()).toJson(), {
'id': 'cid',
'type': 'test',
'frozen': false,
'cooldown': 0,
'truncated_at': currentDate.toIso8601String(),
});
final dateOne = DateTime.now();
var newChannel = channel.copyWith(
extraData: {'truncated_at': dateOne.toIso8601String()},
);
expect(newChannel.extraData['truncated_at'], dateOne.toIso8601String());
expect(newChannel.truncatedAt, dateOne);
final dateTwo = DateTime.now();
newChannel = channel.copyWith(
truncatedAt: dateTwo,
);
expect(newChannel.extraData['truncated_at'], dateTwo.toIso8601String());
expect(newChannel.truncatedAt, dateTwo);
final dateThree = DateTime.now();
newChannel = channel.copyWith(
truncatedAt: dateThree,
extraData: {'truncated_at': dateThree.toIso8601String()},
);
expect(newChannel.extraData['truncated_at'], dateThree.toIso8601String());
expect(newChannel.truncatedAt, dateThree);
});
}